import Vue from 'vue'
import Vuex from 'vuex'
import Utils from '../libs/util'

Vue.use(Vuex)

const state = {
  token: ''
}

const mutations = {
  saveToken (state, params) {
    state.token = params
    Utils.storage_set('token', params)
  }
}

const actions = {
  setToken (context, payload) {
    context.commit('saveToken', payload)
  }
}

export default new Vuex.Store({
  state,
  mutations,
  actions
})
